<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('加工库存列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>厂家：</label>
                                <input type="text" name="factoryName"/>
                            </li>
                            <li>
                                <label>原膜编号：</label>
                                <input type="text" name="number"/>
                            </li>
                            <li>
                                <label>加工状态：</label>
                                <select name="status">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${@dict.getType('process_inventory_status')}"
                                            th:value="${dict.dictValue}" th:text="${dict.dictLabel}"></option>
                                </select>
                            </li>
                            <li>
                                <label>材料规格：</label>
                                <input type="text" name="mSpecification"/>
                            </li>
                            <li>
                                <label>入库状态：</label>
                                <select name="type">
                                    <option value="">所有</option>
                                    <option value="1">出库</option>
                                    <option value="2">入库</option>
                                </select>
                            </li>
                            <li class="select-time">
                                <label>来料日期：</label>
                               <!--  <input type="text" class="time-input" id="startTime" placeholder="来料日期" name="startTime"/> -->
                                <input type="text" class="form-control" id="startTime" name="startTime" >
                            </li>
                            <li>
                                <label>记录人：</label>
                                <input type="text" name="productDemand"/>
                            </li>
                            <li class="select-time">
                                <label>入库日期：</label>
                               <!--  <input type="text"   id="endTime" placeholder="入库日期" name="endTime"/> -->
                                
                                <input type="text" class="form-control" id="endTime2" name="endTime2" >
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="process:inventory:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <!--<a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="process:inventory:edit">-->
                    <!--<i class="fa fa-edit"></i> 修改-->
                <!--</a>-->
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="process:inventory:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="process:inventory:export">
                    <i class="fa fa-download"></i> 导出
                </a>
                
                 <a class="btn btn-warning" onclick="g()">
                    <i class="fa fa-download"></i> 导出跟踪单
                </a>
                <a class="btn btn-warning" onclick="f()">
                    <i class="fa fa-download"></i> 导出发货单单
                </a>
            </div>
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
       <th:block th:include="include :: datetimepicker-js" />
       
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('process:inventory:edit')}]];
        var removeFlag = [[${@permission.hasPermi('process:inventory:remove')}]];
        var prefix = ctx + "process/inventory";

    
        $(function() {
        	
          	$("#endTime2").datetimepicker({
       		    format: "yyyy-mm-dd",
       		    minView: "month",
       		    autoclose: true
       		});
          	$("#startTime").datetimepicker({
       		    format: "yyyy-mm-dd",
       		    minView: "month",
       		    autoclose: true
       		});
        	
        	
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "加工库存",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'id',
                    title: 'id',
                    visible: false
                },
                {
                    field: 'factoryName',
                    title: '厂家'
                },
                {
                    field: 'number',
                    title: '原膜编号'
                },
                {
                    field: 'status',
                    title: '加工状态',
                    formatter: function(value, row, index) {
                        if(value==1){return '未加工'}
                        if(value==2){return '并卷'}
                        if(value==3){return '镀铝'}
                        if(value==4){return '分卷'}
                    }
                },
                {
                    field: 'type',
                    title: '出库状态',
                    formatter: function(value, row, index) {
                        if(value==1){return '出库'}
                        if(value==2){return '入库'}
                    }
                },
                {
                    field: 'materialsName',
                    title: '材料名称'
                },
                {
                    field: 'color',
                    title: '颜色'
                },
                {
                    field: 'mSpecification',
                    title: '材料规格',
                    formatter: function(value, row, index) {
                        return value+"("+row.specificationUnit+")";
                    }
                },
                {
                    field: 'mLength',
                    title: '材料长度',
                    formatter: function(value, row, index) {
                        return value+"m";
                    }
                },
                {
                    field: 'productWeigt',
                    title: '产品重量',
                    formatter: function(value, row, index) {
                        return value+"("+row.weigtUnit+")";
                    }
                },
                {
                    field: 'aluminizedWeigt',
                    title: '镀铝重量',
                    formatter: function(value, row, index) {
                        return value+"("+row.aluminizedUnit+")";
                    }
                },
                {
                    field: 'mDate',
                    title: '来料日期'
                },
                {
                    field: 'createBy',
                    title: '记录人'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
        
        function g(){
        	var ids = $.table.selectColumns("id");
        	if(ids.length < 1){
        		$.modal.alertError("请选择");
        		return ;
        	}
        	
        	var url   = "./inventory/print?ids="+ids;
        	window.open(url,"_blank");    
        }
        function f(){
        	var ids = $.table.selectColumns("id");
        	if(ids.length < 1){
        		$.modal.alertError("请选择一个");
        		return ;
        	}
        	var code = 0;
        	var idsa = ids.toString();
        	$.ajax({
				type : "POST",
				url : "../process/inventory/gzd?ids="+idsa,
				success : function(r) {
					code = r.code;
					if (r.code != 0) {
						$.modal.alertError(r.msg);
					}
				},complete: function(){
					if (code == 0) {
						window.location.href  = "../process/inventory/gzdd?ids="+idsa;
					}
				}
			});
        	
        	
        }
    </script>
</body>
</html>